package com.flux.utils

import android.content.Context
import android.widget.Toast

/**
 * Created by hsy on 2016/4/7.
 */
object ToastUtil {
    private var toast: Toast? = null

    fun showToast(applicationContext: Context, msg: String) {
        if (null == toast) {
            toast = Toast.makeText(applicationContext, msg, Toast.LENGTH_SHORT)
        } else {
            toast!!.setText(msg)
        }
        toast!!.show()
    }

    fun showToast(applicationContext: Context, msg: Int) {
        ToastUtil.showToast(applicationContext, applicationContext.getString(msg))
    }

    fun cancelToast() {
        if (null != toast) {
            toast!!.cancel()
        }
    }
}
